const express = require('express');
const test = express();
const XML = require('../utils/ObjTree');
const { getRoute } = require('../model/index');
const ObjTree = new XML.ObjTree()


test.get('/getRoute', async function (req, res, next) {
  console.log(req.query)
  
  const data = await getRoute()
  res.send({
    code: 200,
    msg: 'success',
    data
  });
});


test.get('/xml2json', function (req, res, next) {
  const a = {
    root: {
      '@key': "12312312",
      option: [{
        userId: 1, userInfo: 2
      }, {
        userId: 1, userInfo: 2
      }, {
        userId: 1, userInfo: 2
      }]
    }
  }
  const b = ObjTree.writeXML(a)
  res.send(b);
});

module.exports = test;
